// 路由中对应的层
function Layer(path, handler) {
  this.path = path;
  this.handler = handler;
}
Layer.prototype.match = function (path) {
  if (this.path === path) {
    return true;
  }
  if (!this.route) {
    // 中间件
    if (this.path === "/") {
      // 中间件是/都能匹配
      return true;
    }
    return path.startsWith(this.path + "/");
  }
  return false;
};

Layer.prototype.handle_request = function (req, res, next) {
  return this.handler(req, res, next);
};
export default Layer;
